From def1544a03c3ea73897913f44d78fd8f426fe539 Mon Sep 17 00:00:00 2001 From: "cl349@firebug.cl.cam.ac.uk" Date: Tue, 6 Sep 2005 18:29:27 +0000 Subject: [PATCH] Use @releaseDomain watch-events. This replaces listening to the domain exception virq through xcs. Signed-off-by: Christian Limpach --- tools/console/Makefile | 1 - tools/console/daemon/io.c | 21 +------ tools/console/daemon/utils.c | 111 ++++------------------------------- tools/console/daemon/utils.h | 2 - 4 files changed, 11 insertions(+), 124 deletions(-) diff --git a/tools/console/Makefile b/tools/console/Makefile index cd88497f5f..3e1471d99c 100644 --- a/tools/console/Makefile +++ b/tools/console/Makefile @@ -11,7 +11,6 @@ INSTALL_DIR = $(INSTALL) -d -m0755 CFLAGS += -Wall -Werror -g3 -CFLAGS += -I $(XEN_XCS) CFLAGS += -I $(XEN_LIBXC) CFLAGS += -I $(XEN_XENSTORE) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 4545dd39fa..1bcdfdf04d 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -26,7 +26,6 @@ #include "xenctrl.h" #include "xs.h" #include "xen/io/domain_controller.h" -#include "xcs_proto.h" #include #include @@ -462,18 +461,6 @@ static void handle_ring_read(struct domain *dom) (void)write_sync(dom->evtchn_fd, &v, sizeof(v)); } -static void handle_xcs_msg(int fd) -{ - xcs_msg_t msg; - - if (!read_sync(fd, &msg, sizeof(msg))) { - dolog(LOG_ERR, "read from xcs failed! %m"); - exit(1); - } - - enum_domains(); -} - static void handle_xs(int fd) { char **vec; @@ -484,7 +471,7 @@ static void handle_xs(int fd) if (!vec) return; - if (!strcmp(vec[1], "introduceDomain")) + if (!strcmp(vec[1], "domlist")) enum_domains(); else if (sscanf(vec[1], "dom%u", &domid) == 1) { dom = lookup_domain(domid); @@ -509,9 +496,6 @@ void handle_io(void) FD_ZERO(&readfds); FD_ZERO(&writefds); - FD_SET(xcs_data_fd, &readfds); - max_fd = MAX(xcs_data_fd, max_fd); - FD_SET(xs_fileno(xs), &readfds); max_fd = MAX(xs_fileno(xs), max_fd); @@ -536,9 +520,6 @@ void handle_io(void) if (FD_ISSET(xs_fileno(xs), &readfds)) handle_xs(xs_fileno(xs)); - if (FD_ISSET(xcs_data_fd, &readfds)) - handle_xcs_msg(xcs_data_fd); - for (d = dom_head; d; d = n) { n = d->next; if (d->evtchn_fd != -1 && diff --git a/tools/console/daemon/utils.c b/tools/console/daemon/utils.c index 9ffe04ebe5..985de2061a 100644 --- a/tools/console/daemon/utils.c +++ b/tools/console/daemon/utils.c @@ -35,16 +35,12 @@ #include "xenctrl.h" #include "xen/io/domain_controller.h" -#include "xcs_proto.h" #include "utils.h" struct xs_handle *xs; int xc; -int xcs_ctrl_fd = -1; -int xcs_data_fd = -1; - bool _read_write_sync(int fd, void *data, size_t size, bool do_read) { size_t offset = 0; @@ -71,32 +67,6 @@ bool _read_write_sync(int fd, void *data, size_t size, bool do_read) return true; } -static int open_domain_socket(const char *path) -{ - struct sockaddr_un addr; - int sock; - size_t addr_len; - - if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) { - goto out; - } - - addr.sun_family = AF_UNIX; - strcpy(addr.sun_path, path); - addr_len = sizeof(addr.sun_family) + strlen(XCS_SUN_PATH) + 1; - - if (connect(sock, (struct sockaddr *)&addr, addr_len) == -1) { - goto out_close_sock; - } - - return sock; - - out_close_sock: - close(sock); - out: - return -1; -} - static void child_exit(int sig) { while (waitpid(-1, NULL, WNOHANG) > 0); @@ -155,34 +125,8 @@ void daemonize(const char *pidfile) signal(SIGTTIN, SIG_IGN); } -/* synchronized send/recv strictly for setting up xcs */ -/* always use asychronize callbacks any other time */ -static bool xcs_send_recv(int fd, xcs_msg_t *msg) -{ - bool ret = false; - - if (!write_sync(fd, msg, sizeof(*msg))) { - dolog(LOG_ERR, "Write failed at %s:%s():L%d? Possible bug.", - __FILE__, __FUNCTION__, __LINE__); - goto out; - } - - if (!read_sync(fd, msg, sizeof(*msg))) { - dolog(LOG_ERR, "Read failed at %s:%s():L%d? Possible bug.", - __FILE__, __FUNCTION__, __LINE__); - goto out; - } - - ret = true; - - out: - return ret; -} - bool xen_setup(void) { - int sock; - xcs_msg_t msg; xs = xs_daemon_open(); if (xs == NULL) { @@ -197,58 +141,23 @@ bool xen_setup(void) goto out; } - sock = open_domain_socket(XCS_SUN_PATH); - if (sock == -1) { - dolog(LOG_ERR, "Failed to contact xcs (%m). Is it running?"); - goto out_close_store; - } - - xcs_ctrl_fd = sock; - - sock = open_domain_socket(XCS_SUN_PATH); - if (sock == -1) { - dolog(LOG_ERR, "Failed to contact xcs (%m). Is it running?"); - goto out_close_ctrl; - } - - xcs_data_fd = sock; - - memset(&msg, 0, sizeof(msg)); - msg.type = XCS_CONNECT_CTRL; - if (!xcs_send_recv(xcs_ctrl_fd, &msg) || msg.result != XCS_RSLT_OK) { - dolog(LOG_ERR, "xcs control connect failed. Possible bug."); - goto out_close_data; - } - - msg.type = XCS_CONNECT_DATA; - if (!xcs_send_recv(xcs_data_fd, &msg) || msg.result != XCS_RSLT_OK) { - dolog(LOG_ERR, "xcs data connect failed. Possible bug."); - goto out_close_data; - } - - msg.type = XCS_VIRQ_BIND; - msg.u.virq.virq = VIRQ_DOM_EXC; - if (!xcs_send_recv(xcs_ctrl_fd, &msg) || msg.result != XCS_RSLT_OK) { - dolog(LOG_ERR, "xcs virq bind failed. Possible bug."); - goto out_close_data; + if (!xs_watch(xs, "@introduceDomain", "domlist")) { + dolog(LOG_ERR, "xenstore watch on @introduceDomain fails."); + goto out; } - if (!xs_watch(xs, "@introduceDomain", "introduceDomain")) { - dolog(LOG_ERR, "xenstore watch on @introduceDomain fails."); - goto out_close_data; + if (!xs_watch(xs, "@releaseDomain", "domlist")) { + dolog(LOG_ERR, "xenstore watch on @releaseDomain fails."); + goto out; } return true; - out_close_data: - close(xcs_data_fd); - xcs_data_fd = -1; - out_close_ctrl: - close(xcs_ctrl_fd); - xcs_ctrl_fd = -1; - out_close_store: - xs_daemon_close(xs); out: + if (xs) + xs_daemon_close(xs); + if (xc != -1) + xc_interface_close(xc); return false; } diff --git a/tools/console/daemon/utils.h b/tools/console/daemon/utils.h index 584c6bd4e0..6dc6f0d49d 100644 --- a/tools/console/daemon/utils.h +++ b/tools/console/daemon/utils.h @@ -33,8 +33,6 @@ bool xen_setup(void); #define write_sync(fd, buffer, size) _read_write_sync(fd, buffer, size, false) bool _read_write_sync(int fd, void *data, size_t size, bool do_read); -extern int xcs_ctrl_fd; -extern int xcs_data_fd; extern struct xs_handle *xs; extern int xc; -- 2.30.2